package de.cau.apo.problems.strippacking;

/**
 * This class represents a rectangle for the strip packing problem.
 * It has a fixed index and fixed dimension (width and height).
 * The user has the ability to give this rectangle a specific position via 
 * the x and y fields. This positions are used to calculate the 
 * dimension of the strip where all rectangles shall be lie in.
 *  
 * @author Marius Richter
 *
 */
public class Rectangle {

	// ########### properties ###########
	
	/** the index of this rectangle */
	public final int index;
	/** the width of this rectangle*/
	public final float width;
	/** the height of this rectangle */
	public final float height;
	/** the position in x direction of this rectangle in the strip */
	public float x;
	/** the position in y direction of this rectangle in the strip */
	public float y;
	
	// ########### instantiation ###########
	
	/**
	 * Creates a new rectangle object
	 * @param index the index for this rectangle
	 * @param width the width for this rectangle
	 * @param height the height for this rectangle
	 */
	public Rectangle(int index, float width, float height) {
		this.index = index;
		this.width = width;
		this.height = height;
		this.x = -1;
		this.y = -1;
	}
	
	// ########### getter/setter ###########
	
	/**
	 * @return the index of this rectangle
	 */
	public int getIndex() {
		return index;
	}
	
	/**
	 * @return the width of this rectangle
	 */
	public float getWidth() {
		return width;
	}
	
	/**
	 * @return the height of this rectangle
	 */
	public float getHeight() {
		return height;
	}
	
	/**
	 * @return the position in x direction of this rectangle in the strip
	 */
	public float getX() {
		return x;
	}
	
	/**
	 * @param x the new position in x direction of this rectangle in the strip
	 */
	public void setX(float x) {
		this.x = x;
	}
	
	/**
	 * @return the position in y direction of this rectangle in the strip
	 */
	public float getY() {
		return y;
	}
	
	/**
	 * @param y the new position in y direction of this rectangle in the strip
	 */
	public void setY(float y) {
		this.y = y;
	}
	
	/**
	 * @param x the new position in x direction of this rectangle in the strip
	 * @param y the new position in y direction of this rectangle in the strip
	 */
	public void setLocation(float x, float y) {
		this.x = x;
		this.y = y;
	}

	// ########### overriding toString() ###########
	
	@Override
	public String toString() {
		return "Rectangle [index=" + index + ", width=" + width + ", height="
				+ height + ", x=" + x + ", y=" + y + "]";
	}
	
}
